﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace Twittit.WPF
{
	/// <summary>
	/// Logique d'interaction pour Login.xaml
	/// </summary>
	public partial class Login : Window
	{
		public Login()
		{
			this.InitializeComponent();
            this.Name = "Login";
            this.Log.Focus();
            this.DataContext = new LoginViewModel();
			// Insérez le code requis pour la création d’objet sous ce point.
		}

        private void Passwd_PasswordChanged(object sender, RoutedEventArgs e)
        {
            ((LoginViewModel) this.DataContext).Password = ((PasswordBox) sender).Password;
        }

        private void Window_Closed(object sender, EventArgs e)
        {
            foreach (System.Windows.Window w in App.Current.Windows)
            {
                w.Close();
            }
        }

        private void Window_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Enter)
                ((LoginViewModel) this.DataContext).LoginClick();
        }
	}
}